---
- name: Zabbix_agent
  hosts: [web, elk, bastion]
  become: yes
  gather_facts: yes
    
  
  tasks:

  - name: install the Zabbix repository
    get_url:
        url: https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian11_all.deb
        dest: /tmp/
        mode: '0777'
  - name: dpkg
    apt:
      deb: /tmp/zabbix-release_7.0-1+debian11_all.deb
  
  - name: Install 
    apt:
      update_cache: yes
      name:
        - zabbix-agent
      state: latest

  - name: copy config 
    template:
       src: /home/tandem/Graduate-work/skript/zabbix_agent.j2
       dest: /etc/zabbix/zabbix_agentd.conf
      
 
  - name: Restarted zabbix-agent.service
    service: 
       name: zabbix-agent.service
       state: restarted
       enabled: yes     
